home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / guile-ii.src / guile-ii / guile-src / slib / Template.scm < prev    next >
Encoding:
Text File  |  1995-01-27  |  8.3 KB  |  268 lines

  1. ;"Template.scm" configuration template of *features* for Scheme    -*-scheme-*-
  2. ; Copyright (C) 1991, 1992, 1993 Aubrey Jaffer.
  3. ;
  4. ;Permission to copy this software, to redistribute it, and to use it
  5. ;for any purpose is granted, subject to the following restrictions and
  6. ;understandings.
  7. ;
  8. ;1.  Any copy made of this software must include this copyright notice
  9. ;in full.
  10. ;
  11. ;2.  I have made no warrantee or representation that the operation of
  12. ;this software will be error-free, and I am under no obligation to
  13. ;provide any services, by way of maintenance, update, or otherwise.
  14. ;
  15. ;3.  In conjunction with products arising from the use of this
  16. ;material, there shall be no use of my name in any advertising,
  17. ;promotional, or sales literature without prior written consent in
  18. ;each case.
  19.  
  20. ;;; (software-type) should be set to the generic operating system type.
  21. ;;; UNIX, VMS, MACOS, AMIGA and MS-DOS are supported.
  22.  
  23. (define (software-type) 'UNIX)
  24.  
  25. ;;; (scheme-implementation-type) should return the name of the scheme
  26. ;;; implementation loading this file.
  27.  
  28. (define (scheme-implementation-type) 'Template)
  29.  
  30. ;;; (scheme-implementation-version) should return a string describing
  31. ;;; the version the scheme implementation loading this file.
  32.  
  33. (define (scheme-implementation-version) "?")
  34.  
  35. ;;; (implementation-vicinity) should be defined to be the pathname of
  36. ;;; the directory where any auxillary files to your Scheme
  37. ;;; implementation reside.
  38.  
  39. (define (implementation-vicinity)
  40.   (case (software-type)
  41.     ((UNIX)     "/usr/local/src/scheme/")
  42.     ((VMS)    "scheme$src:")
  43.     ((MS-DOS)    "C:\\scheme\\")))
  44.  
  45. ;;; (library-vicinity) should be defined to be the pathname of the
  46. ;;; directory where files of Scheme library functions reside.
  47.  
  48. (define library-vicinity
  49.   (let ((library-path
  50.      (or
  51.       ;; Use this getenv if your implementation supports it.
  52.       (getenv "SCHEME_LIBRARY_PATH")
  53.       ;; Use this path if your scheme does not support GETENV
  54.       ;; or if SCHEME_LIBRARY_PATH is not set.
  55.       (case (software-type)
  56.         ((UNIX) "/usr/local/lib/slib/")
  57.         ((VMS) "lib$scheme:")
  58.         ((MS-DOS) "C:\\SLIB\\")
  59.         (else "")))))
  60.     (lambda () library-path)))
  61.  
  62. ;;; *FEATURES* should be set to a list of symbols describing features
  63. ;;; of this implementation.  Suggestions for features are:
  64.  
  65. (define *features*
  66.       '(
  67.     source                ;can load scheme source files
  68.                     ;(slib:load-source "filename")
  69. ;    compiled            ;can load compiled files
  70.                     ;(slib:load-compiled "filename")
  71. ;    rev4-report            ;conforms to
  72. ;    rev3-report            ;conforms to
  73. ;    ieee-p1178            ;conforms to
  74. ;    sicp                ;runs code from Structure and
  75.                     ;Interpretation of Computer
  76.                     ;Programs by Abelson and Sussman.
  77. ;    rev4-optional-procedures    ;LIST-TAIL, STRING->LIST,
  78.                     ;LIST->STRING, STRING-COPY,
  79.                     ;STRING-FILL!, LIST->VECTOR,
  80.                     ;VECTOR->LIST, and VECTOR-FILL!
  81. ;    rev2-procedures            ;SUBSTRING-MOVE-LEFT!,
  82.                     ;SUBSTRING-MOVE-RIGHT!,
  83.                     ;SUBSTRING-FILL!,
  84.                     ;STRING-NULL?, APPEND!, 1+,
  85.                     ;-1+, <?, <=?, =?, >?, >=?
  86. ;    multiarg/and-            ;/ and - can take more than 2 args.
  87. ;    multiarg-apply            ;APPLY can take more than 2 args.
  88. ;    rationalize
  89. ;    delay                ;has DELAY and FORCE
  90. ;    with-file            ;has WITH-INPUT-FROM-FILE and
  91.                     ;WITH-OUTPUT-FROM-FILE
  92. ;    string-port            ;has CALL-WITH-INPUT-STRING and
  93.                     ;CALL-WITH-OUTPUT-STRING
  94. ;    transcript            ;TRANSCRIPT-ON and TRANSCRIPT-OFF
  95. ;    char-ready?
  96. ;    macro                ;has R4RS high level macros
  97. ;    defmacro            ;has Common Lisp DEFMACRO
  98. ;    eval                ;SLIB:EVAL is single argument eval
  99. ;    record                ;has user defined data structures
  100. ;    values                ;proposed multiple values
  101. ;    dynamic-wind            ;proposed dynamic-wind
  102. ;    ieee-floating-point        ;conforms to
  103.     full-continuation        ;can return multiple times
  104. ;    object-hash            ;has OBJECT-HASH
  105.  
  106. ;    sort
  107. ;    queue                ;queues
  108. ;    pretty-print
  109. ;    object->string
  110. ;    format
  111. ;    trace                ;has macros: TRACE and UNTRACE
  112. ;    compiler            ;has (COMPILER)
  113. ;    ed                ;(ED) is editor
  114. ;    system                ;posix (system <string>)
  115.     getenv                ;posix (getenv <string>)
  116. ;    program-arguments        ;returns list of strings (argv)
  117. ;    Xwindows            ;X support
  118. ;    curses                ;screen management package
  119. ;    termcap                ;terminal description package
  120. ;    terminfo            ;sysV terminal description
  121. ;    current-time            ;returns time in seconds since 1/1/1970
  122.     ))
  123.  
  124. ;;; (OUTPUT-PORT-WIDTH <port>)
  125. (define (output-port-width . arg) 79)
  126.  
  127. ;;; (OUTPUT-PORT-HEIGHT <port>)
  128. (define (output-port-height . arg) 24)
  129.  
  130. ;;; (CURRENT-ERROR-PORT)
  131. (define current-error-port
  132.   (let ((port (current-output-port)))
  133.     (lambda () port)))
  134.  
  135. ;;; (TMPNAM) makes a temporary file name.
  136. (define tmpnam (let ((cntr 100))
  137.          (lambda () (set! cntr (+ 1 cntr))
  138.              (string-append "slib_" (number->string cntr)))))
  139.  
  140. ;;; (FILE-EXISTS? <string>)
  141. (define (file-exists? f) #f)
  142.  
  143. ;;; (DELETE-FILE <string>)
  144. (define (delete-file f) #f)
  145.  
  146. ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  147. ;;; use this definition if your system doesn't have such a procedure.
  148. (define (force-output . arg) #t)
  149.  
  150. ;;; CALL-WITH-INPUT-STRING and CALL-WITH-OUTPUT-STRING are the string
  151. ;;; port versions of CALL-WITH-*PUT-FILE.
  152.  
  153. ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  154. ;;; be returned by CHAR->INTEGER.
  155. (define char-code-limit 256)
  156.  
  157. ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
  158. (define most-positive-fixnum #x0FFFFFFF)
  159.  
  160. ;;; Return argument
  161. (define (identity x) x)
  162.  
  163. ;;; If your implementation provides eval SLIB:EVAL is single argument
  164. ;;; eval using the top-level (user) environment.
  165. ;(define slib:eval eval)
  166.  
  167. ;;; If your implementation provides R4RS macros:
  168. ;(define macro:eval slib:eval)
  169. ;(define macro:load load)
  170.  
  171. (define *defmacros*
  172.   (list (cons 'defmacro
  173.           (lambda (name parms . body)
  174.         `(set! *defmacros* (cons (cons ',name (lambda ,parms ,@body))
  175.                       *defmacros*))))))
  176. (define (defmacro? m) (and (assq m *defmacros*) #t))
  177.  
  178. (define (macroexpand-1 e)
  179.   (if (pair? e) (let ((a (car e)))
  180.           (cond ((symbol? a) (set! a (assq a *defmacros*))
  181.                      (if a (apply (cdr a) (cdr e)) e))
  182.             (else e)))
  183.       e))
  184.  
  185. (define (macroexpand e)
  186.   (if (pair? e) (let ((a (car e)))
  187.           (cond ((symbol? a)
  188.              (set! a (assq a *defmacros*))
  189.              (if a (macroexpand (apply (cdr a) (cdr e))) e))
  190.             (else e)))
  191.       e))
  192.  
  193. (define gentemp
  194.   (let ((*gensym-counter* -1))
  195.     (lambda ()
  196.       (set! *gensym-counter* (+ *gensym-counter* 1))
  197.       (string->symbol
  198.        (string-append "slib:G" (number->string *gensym-counter*))))))
  199.  
  200. (define base:eval slib:eval)
  201. (define (defmacro:eval x) (base:eval (defmacro:expand* x)))
  202. (define (defmacro:expand* x)
  203.   (require 'defmacroexpand) (apply defmacro:expand* x '()))
  204.  
  205. (define (defmacro:load <pathname>)
  206.   (slib:eval-load <pathname> defmacro:eval))
  207.  
  208. (define (slib:eval-load <pathname> evl)
  209.   (if (not (file-exists? <pathname>))
  210.       (set! <pathname> (string-append <pathname> (scheme-file-suffix))))
  211.   (call-with-input-file <pathname>
  212.     (lambda (port)
  213.       (let ((old-load-pathname *load-pathname*))
  214.     (set! *load-pathname* <pathname>)
  215.     (do ((o (read port) (read port)))
  216.         ((eof-object? o))
  217.       (evl o))
  218.     (set! *load-pathname* old-load-pathname)))))
  219.  
  220. ;;; define an error procedure for the library
  221. ;(define slib:error error)
  222.  
  223. ;;; define these as appropriate for your system.
  224. (define slib:tab (integer->char 9))
  225. (define slib:form-feed (integer->char 12))
  226.  
  227. ;;; Support for older versions of Scheme.  Not enough code for its own file.
  228. (define (last-pair l) (if (pair? (cdr l)) (last-pair (cdr l)) l))
  229. (define t #t)
  230. (define nil #f)
  231.  
  232. ;;; Define these if your implementation's syntax can support it and if
  233. ;;; they are not already defined.
  234.  
  235. ;(define (1+ n) (+ n 1))
  236. ;(define (-1+ n) (+ n -1))
  237. ;(define 1- -1+)
  238.  
  239. (define in-vicinity string-append)
  240.  
  241. ;;; Define SLIB:EXIT to be the implementation procedure to exit or
  242. ;;; return if exitting not supported.
  243. (define slib:exit (lambda args #f))
  244.  
  245. ;;; Here for backward compatability
  246. (define scheme-file-suffix
  247.   (let ((suffix (case (software-type)
  248.           ((NOSVE) "_scm")
  249.           (else ".scm"))))
  250.     (lambda () suffix)))
  251.  
  252. ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
  253. ;;; suffix all the module files in SLIB have.  See feature 'SOURCE.
  254.  
  255. (define (slib:load-source f) (load (string-append f ".scm")))
  256.  
  257. ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
  258. ;;; by compiling "foo.scm" if this implementation can compile files.
  259. ;;; See feature 'COMPILED.
  260.  
  261. (define slib:load-compiled load)
  262.  
  263. ;;; At this point SLIB:LOAD must be able to load SLIB files.
  264.  
  265. (define slib:load slib:load-source)
  266.  
  267. (slib:load (in-vicinity (library-vicinity) "require"))
  268.